<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>钱吧管理</title>
		<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
	</head>
	<body>
		<p>钱吧列表
		</p>
	<table id="table" border="1" cellspacing="0" cellpadding="0" >
		<thead style="background-color: lavender;">
		   	<tr style="height: 40px;">
				<th>钱吧编码</th>
		        <th>钱吧名称</th>
		        <th>钱吧Logo地址</th>
		        <th style="width:40px;">处理</th>
		        <th>状态</th>
		        <th>首页是否显示</th>
		        <th>首页显示顺序</th>
			</tr>
	    </thead>
	    <tbody id = "moneyBarList"></tbody>
	</table>
	</body>
<script>
	$(document).ready(function() {
		var reqData = {
			"token" : "8155bc545f84d9652f1012ef2bdfb6eb"
		};
		var opt = {
			"reqData" : reqData
		};

		$.ajax({
			type : "post",
			url : "/dz-lm-web/h5/weijie/qryMoneyBarList.do",
			dataType : "json",
			contentType : "application/json",
			data : JSON.stringify(opt),
			success : function(d) {
				var moneyBarList = d.moneyBarList;
				var tbody = $("#moneyBarList").empty();
				$.each(moneyBarList, function(index, item){
					var state = item.state;
					if (item.state == '0') {
						state = "<a href ='#' onclick ='audit(" + item.barId + ",1)'>审核</a>";
					} else {
						state = "<a href ='#' onclick ='audit(" + item.barId + ",0)'>下架</a>";
					}
					if (parseInt(index%2) == 0) {
						tbody.append("<tr><td>" + item.barId + "</td><td>" + item.barName + "</td><td><img style='width:50px;height:50px;' src='" + 
								item.barLogoImage + "'></img></td><td>" + state + "</td><td>" + 
								item.stateName + "</td><td>" + item.homeDisplayFlag + "</td><td>" + item.displaySort + "</td></tr>");
					} else {
						tbody.append("<tr style='background: honeydew;'><td>" + item.barId + "</td><td>" + item.barName + "</td><td><img style='width:50px;height:50px;' src='" + 
								item.barLogoImage + "'></img></td><td>" + state + "</td><td>" + 
							item.stateName + "</td><td>" + item.homeDisplayFlag + "</td><td>" + item.displaySort + "</td></tr>");
					}
				})
			}
		});
	});
	
	function audit(barId, flag){
		var reqData = {
			"token" : "8155bc545f84d9652f1012ef2bdfb6eb",
			"barId" : barId,
			"auditFlag" : flag
		};
		var opt = {
			"reqData" : reqData
		};
	    $.ajax({
			type : "post",
			url : "/dz-lm-web/h5/weijie/auditMoneyBar.do",
			dataType : "json",
			contentType : "application/json",
			data : JSON.stringify(opt),
			success : function(d) {
				location.reload();
				alert("审核成功");
			}
		});
	}
</script>
</html>